//
//  TeacherCallNameConfirmCell.m
//  AttendenceSys
//
//  Created by ld on 16/1/28.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "TeacherCallNameConfirmCell.h"

@implementation TeacherCallNameConfirmCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self initCell];
    }
    return self;
}

- (void)initCell
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    _nameLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, [UIScreen mainScreen].bounds.size.width-20-30-45, 25)];
    [_nameLab setBackgroundColor:[UIColor clearColor]];
    _nameLab.font = [UIFont systemFontOfSize:16];
    [_nameLab setTextAlignment:NSTextAlignmentLeft];
    _nameLab.textColor = [UIColor blackColor];
    [self.contentView addSubview:_nameLab];
    
    
    _lateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _lateBtn.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-30-45-120,11,45,23);
    [_lateBtn setTitle:@"迟到" forState:UIControlStateNormal];
    
    _lateBtn.layer.masksToBounds = YES;
    _lateBtn.layer.cornerRadius = 4.5;
    _lateBtn.layer.borderWidth = 1.0;
    
    [_lateBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [_lateBtn addTarget:self action:@selector(callName:) forControlEvents:UIControlEventTouchUpInside];
    
    [_lateBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    [self.contentView addSubview:_lateBtn];
    
    
    _callNameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _callNameBtn.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-30-45-60,11,45,23);
    [_callNameBtn setTitle:@"旷课" forState:UIControlStateNormal];
    
    _callNameBtn.layer.masksToBounds = YES;
    _callNameBtn.layer.cornerRadius = 4.5;
    _callNameBtn.layer.borderWidth = 1.0;
    
    [_callNameBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [_callNameBtn addTarget:self action:@selector(callName:) forControlEvents:UIControlEventTouchUpInside];
    
    [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    [self.contentView addSubview:_callNameBtn];
    
    
    _leaveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _leaveBtn.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-30-45,11,45,23);
    [_leaveBtn setTitle:@"请假" forState:UIControlStateNormal];
    
    _leaveBtn.layer.masksToBounds = YES;
    _leaveBtn.layer.cornerRadius = 4.5;
    _leaveBtn.layer.borderWidth = 1.0;
    
    [_leaveBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [_leaveBtn addTarget:self action:@selector(leave:) forControlEvents:UIControlEventTouchUpInside];
    
    [_leaveBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    [self.contentView addSubview:_leaveBtn];
    
    _callStustatusLab = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-30-60,11,60,23)];
    [_callStustatusLab setBackgroundColor:[UIColor clearColor]];
    _callStustatusLab.font = [UIFont systemFontOfSize:13];
    [_callStustatusLab setTextAlignment:NSTextAlignmentRight];
    _callStustatusLab.textColor = RGB(102, 102, 102);
    _callStustatusLab.hidden = YES;
    [self.contentView addSubview:_callStustatusLab];
    
    
    UIImageView* lineView = [[UIImageView alloc] initWithFrame:CGRectMake(0,CallNameCellHeight-1,[UIScreen mainScreen].bounds.size.width,1)];
    [lineView setBackgroundColor:RGB(240, 240, 240)];
    [self.contentView addSubview:lineView];
}

-(void)leave:(id)sender
{
    UIButton* btn = (UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(getIsSelect:)]) {
        [_delegate getIsSelect:btn.tag];
    }
}

-(void)callName:(id)sender
{
    UIButton* btn = (UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(getIsSelect:)]) {
        [_delegate getIsSelect:btn.tag];
    }
}

-(void)setselectCallName:(NSString*)sType
{
    NSInteger type = [sType integerValue];
    if (defaultCallNameSelectTag == type) {
        
        _callNameBtn.backgroundColor = [UIColor whiteColor];
        [_callNameBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        _lateBtn.backgroundColor = [UIColor whiteColor];
        [_lateBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_lateBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        _leaveBtn.backgroundColor = [UIColor whiteColor];
        [_leaveBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_leaveBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        
    }
    else if (2 == type)
    {
        _lateBtn.backgroundColor = RGB(242, 94, 95);
        [_lateBtn.layer setBorderColor:[UIColor clearColor].CGColor];
        [_lateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _callNameBtn.backgroundColor = [UIColor whiteColor];
        [_callNameBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        _leaveBtn.backgroundColor = [UIColor whiteColor];
        [_leaveBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_leaveBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        
    }
    else if (3 == type)
    {
        _callNameBtn.backgroundColor = RGB(242, 94, 95);
        [_callNameBtn.layer setBorderColor:[UIColor clearColor].CGColor];
        [_callNameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _lateBtn.backgroundColor = [UIColor whiteColor];
        [_lateBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_lateBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        _leaveBtn.backgroundColor = [UIColor whiteColor];
        [_leaveBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_leaveBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    }
    else
    {
        _leaveBtn.backgroundColor = RGB(242, 94, 95);
        [_leaveBtn.layer setBorderColor:[UIColor clearColor].CGColor];
        [_leaveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _callNameBtn.backgroundColor = [UIColor whiteColor];
        [_callNameBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        _lateBtn.backgroundColor = [UIColor whiteColor];
        [_lateBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_lateBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    }
}


@end
